package com.xiaoshangkou.hellopra;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan("com.xiaoshangkou.hellopra.mapper")//扫描包放入spring容器中，持久层这样mybatisplus才能扫描到
//Springboot启动时扫描注解标注的web组件
@ServletComponentScan
public class HelloPraApplication {

    public static void main(String[] args) {
        SpringApplication.run(HelloPraApplication.class, args);
    }
    //MybatisPlus注册插件
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //插件注册器
        MybatisPlusInterceptor interceptor=new MybatisPlusInterceptor();
        //添加分页查询插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
